Use case: ICACHE error interrupt

This use case shows how ICACHE reports errors via interrupt and callback, comparing HAL1 and HAL2.

Sequence diagram

    @startuml
    participant "User\nApplication" order 1
    participant "ICACHE\nDriver" order 2
    participant "ICACHE_IRQHandler" order 3
    "User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_Enable
    note right: with Error IT enabled
    "ICACHE\nDriver"-->"User\nApplication":HAL_OK
    note left: return\nstatus
    == Interruption Service Routine ==
    "ICACHE_IRQHandler" <-]:Error interrupt
    "ICACHE_IRQHandler" -> "ICACHE\nDriver": HAL_ICACHE_IRQHandler
    note left: Interruption execution
    "ICACHE\nDriver"->"User\nApplication":HAL_ICACHE_ErrorCallback()
    @enduml

Code snippet

HAL1

HAL2

/* Enable ICACHE and its error interrupt (device-specific setup may apply) */
HAL_ICACHE_Enable();

/* In ICACHE_IRQHandler(): */
/* HAL_ICACHE_IRQHandler(); */

/* Error notification */
/* void HAL_ICACHE_ErrorCallback(void) { ... } */
/* Optional: register callback */
(void)HAL_ICACHE_RegisterErrorCallback(&hicache1, ICACHE_Error_UserCallback);

/* Start ICACHE with error interrupt enabled */
if (HAL_ICACHE_Start(&hicache1, HAL_ICACHE_IT_ERROR) != HAL_OK)
{
  Error_Handler();
}

/* In ICACHE_IRQHandler(): */
/* HAL_ICACHE_IRQHandler(&hicache1); */

Key changes

  1. HAL2 exposes error interrupt enable via HAL_ICACHE_Start(..., HAL_ICACHE_IT_ERROR) instead of separate macro-based interrupt enabling.

  2. HAL2 supports callback registration (HAL_ICACHE_RegisterErrorCallback()) when enabled at compile time.

  3. The IRQ flow remains: the ICACHE ISR calls HAL_ICACHE_IRQHandler(), which then dispatches to the user callback.